package code.class3.easy;

/**
 * https://leetcode.cn/problems/zuo-xuan-zhuan-zi-fu-chuan-lcof/
 * 动态口令
 */
public class Code04_dynamicPassword {

    public static void main(String[] args) {
        String password = "s3cur1tyC0d3";
        int target = 4;
        String res = dynamicPassword2(password, target);
        System.out.println("res = " + res);
    }

    public static String dynamicPassword2(String str, int target) {
        return str.substring(target) + str.substring(0, target);
    }

    /**
     * 使用指针写法
     */
    public static String dynamicPassword(String str, int target) {
        char[] arr = (str + str).toCharArray();
        int p1 = 0;
        while (target-- > 0) {
            p1++;
        }
        return new String(arr,p1,str.length());
    }
}
